/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package database;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import model.Barang;

/**
 *
 * @author elfatah
 */
public class DBBarang extends DBClass{
    
    public List getBarangDetails() throws SQLException, ClassNotFoundException {

        Connection con = createConnection();
        PreparedStatement pstmt = con.prepareStatement("select * from barang");
        ResultSet rs = pstmt.executeQuery();
        List list = new ArrayList();
        while (rs.next()) {
            Barang ubean = new Barang();
            ubean.setBarangId(Integer.parseInt(rs.getString(1)));
            ubean.setKodeBarang(rs.getString(2));
//            ubean.setAlamat(rs.getString(3));
//            ubean.setTanggalLahir(rs.getString(4));
//            ubean.setKelamin(rs.getString(5));
//            ubean.setTelp(rs.getString(6));
//            ubean.setPekerjaan(rs.getString(7));
//            ubean.setAgama(rs.getString(8));

            list.add(ubean);

        }
        return list;
    }
    
}
